<!DOCTYPE html>
<html>

	<head lang="en">
		<title>找攻略</title>
		<!--<embed src="deng.mp3" hidden="true" autostart="true" loop="true">-->
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		
		   <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
			<script src="/js/jquery/jquery.min.js"></script>
			<script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
			<link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
			<link rel="stylesheet" href="/css/reset.css"/>
			<link rel="stylesheet" href="/css/strategyComment.css" />
			<script src="/js/plugins/jrender/jrender.min.js"></script>
			<link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
			<script src="/js/common.js"></script>
			<script src="/js/checkLogin.js"></script>
			<script src="/js/plugins/dialog2/dialog.min.js"></script>
			<script>

				$(function () {
                    var params = getParams();
                    var parentId =''
                    //params.id,当前大评论的id
					//params.strategyId,关联的大攻略的id
                    //根据大评论的id查找评论详情


                    $.get(baseUrl+"/comments/"+params.id,function (data) {
                        console.log(data.strategy);
                        //data是响应回来的strategyComment对象
						$(".row").renderValues(data,{
						    getHref:function(item,value){
                                var url = $(item).data('url');
                                $(item).attr("href",url+value);
                        }
						});
                    });

                    $('.submitBtn').click(function () {
                        console.log(user);
                        var discusscontent = $('#discussComment').val();
                        parentId ='';
                        console.log(params.id);
                        console.log(discusscontent);
                        if(discusscontent == ""){
                            $(document).dialog({
                                overlayClose: true,
                                content: '亲，你还没有输入内容',
                            });
                            return
                        }
                        $.ajax({
							url:baseUrl+"/discusses",
                            type:"post",
							data:{
                                discussContent:discusscontent,
								parentId:parentId,
                                articelId:params.id,
                                "user.id": user.id
							},
							success:function (data) {
                                //清空评论框
                                $(document).dialog({
                                    type : 'confirm',
                                    closeBtnShow: true,
                                    style: 'ios',
                                    content: '评论成功',
                                    onClickConfirmBtn: function(){
                                        $("#discussComment").val("");
                                        var string ='strategyComment.html?id='+params.id+'&'+params.strategyId
                                        window.location.href=string;
                                    }
                                });
                            }
						})
                    })
					$.get(baseUrl+"/discusses/"+params.id,function (data) {
							$('#commentReplyBtn').renderValues(data,{
                                getParentId: function (item, value) {
                                    //console.log(value);
                                    $(item).attr("data-id", value);
                                },
								getHref:getHref
							})
                        $('.replyBtn').click(function () {
                            $('#hotModal').modal('show')
                            parentId = $(this).data('id');
                            $('.submit-Btn').click(function () {
                                var discusscontent = $('#replyContent').val();
                                console.log(discusscontent);
                                if(discusscontent == ""){
                                    $(document).dialog({
                                        overlayClose: true,
                                        content: '亲，回复内容不能为空'
                                    });
                                    return
                                }
                                $.ajax({
                                    url:baseUrl+"/discusses",
                                    type:"post",
                                    data:{
                                        discussContent:discusscontent,
                                        parentId:parentId,
                                        articelId:params.id,
                                        "user.id": user.id
                                    },
                                    success:function (data) {
                                        $(document).dialog({
                                            type : 'confirm',
                                            closeBtnShow: true,
                                            style: 'ios',
                                            content: '回复成功',
                                            onClickConfirmBtn: function(){
                                                //清空评论框
                                                $("#discussComment").val("");
                                                var string ='strategyComment.html?id='+params.id+'&'+params.strategyId
                                                window.location.href=string
                                            }
                                        });

                                    }
                                })
                            })
                        })

                    });

                })
			</script>
	</head>

	<body>
	<div class="modal fade" id="hotModal" tabindex="-1" role="dialog"
		 aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-body">
					<form class="form-horizontal" action="" method="post" id="editForm">
						<div class="form-group" >
							<label class="col-sm-4 control-label">回复内容</label>
							<div class="col-sm-6">
								<textarea id="replyContent" name="replyContent" cols='60' rows='5'></textarea>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary submit-Btn">
						<span class="glyphicon glyphicon-saved"></span> 确认回复
					</button>
				</div>
			</div>
		</div>
	</div>
		<div class="search-head">
			<div class="row nav-search">
				<div class="col">
					<a href="/index.html">
						<span><i class="fa fa-chevron-left"></i></span>
					</a>
				</div>
				<div class="col">
					<span>点评详情</span>
				</div>
				<div class="col"></div>
			</div>
		</div>

			<div class="comment">
			<div class="container ">
				<div class="row">
						<div class="col-2 comment-head">
							<a data-url="/userProfiles.html?id="  render-key="user.id" render-fun="getHref">
								<img class="rounded-circle" render-src="user.headImgUrl">
							</a>
							<button class="btn" id="followBtn"><i class="fa fa-hand-o-right"> </i> 关注</button>
						</div>
						<div class="col">
							<span class="comment-star"  ><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i></span>

							<span class="comment-date" render-html="createTime">2018-07-11</span>
							<div class="comment-content">
								<p render-html="content"></p>
							</div>
							<ul class="comment-img">
								<div render-loop="imgUrlsArr">
								<li>
									<img  render-src="imgUrlsArr.self">
								</li>
								</div>

								<!--<li>
									<img  src="/upload/7d437f8d-a476-465c-bd84-e93a03d8efd5.jpeg">
								</li>-->
							</ul>
							<div class="comment-link">
								<a data-url="/strategyCatalogs.html?id=" render-key="strategy.id" render-fun="getHref">
									<img  render-src="strategy.coverUrl"> <span render-html="strategy.title">广州攻略</span>
									<i class="fa fa-angle-right fa-2x"></i>
								</a>
							</div>
						</div>
				</div>
			</div>

			<div class="count d-flex justify-content-between">
					<div class="p-2">评论<span >0</span></div>
					<div class="p-2">赞<span >0</span></div>
			</div>

			</div>
		<div id="commentJump" class="user-comment">
			<h6 class="comment-topic">发表评论</h6>
			<div class="comment-edit-box clearfix">
				<div class="comment-edit-main">
					<div class="comment-edit">
						<div class="comment-content">
							<div class="comment-text">
								<textarea name="discussComment" id="discussComment" cols='65' rows='5' placeholder="说两句，撩一撩"></textarea>
							</div>
							<button type="button" class="btn btn-primary submitBtn">
								<span class="glyphicon glyphicon-saved"></span> 发表评论
							</button>
						</div>
					</div>
				</div>
			</div>
		</div><br/><br/><br/><br/>

		<h6 class="comment-topic">网友评论</h6>
		<!--<div id="di">
		<ul class="list-group comment_list" render-loop="list">
			<rl><img render-src="list.user.headImgUrl" width="50px"></rl>
			<rl class="list-group-item" render-html="list.discussContent"/>
		</ul>
		</div>-->
		<hr/>
		<div id="commentReplyBtn">
			<div render-loop="list">
				<div class="row">
					<div class="col-2 comment-head">
						<a data-url="/userProfiles.html?id=" render-fun="getHref"
						   render-key="list.user.id">
							<img class="rounded-circle" render-src="list.user.headImgUrl">
						</a>
					</div>
					<div class="col">
						<a style="font-size: 10px;color: #61CAD0"
						   render-html="list.user.nickName"></a>
						<span class="comment-content">发表于</span><span class="comment-date" render-html="list.discussTime"></span>
						<!--<span class="travelCommentBtn" render-key="list.parentId" render-fun="getParentId">回复</span>-->
						<span class="replyBtn" render-key="list.id" render-fun="getParentId">回复ta</span>
						<div class="comment-content">
							<p render-html="list.discussContent"></p>
						</div>
						<hr/>
						<div render-loop="list.discusses">
							<div class="row">
								<div class="col-2 comment-head">
								<a data-url="/userProfiles.html?id=" render-fun="getHref"
									   render-key="list.discusses.user.id">
										<img class="rounded-circle" render-src="list.discusses.user.headImgUrl">
									</a>
								</div>
								<div class="col">
									<a style="font-size: 10px;color: #61CAD0"
									   render-html="list.discusses.user.nickName"></a>
									<span class="comment-content"></span><span class="comment-date" render-html="list.discusses.discussTime"></span>回复<a style="font-size: 10px;color: #61CAD0"
																																						  render-html="list.user.nickName"></a>
									<span class="replyBtn" render-key="list.discusses.id" render-fun="getParentId">回复ta</span>
									<div class="comment-content">
										<p render-html="list.discusses.discussContent"></p>
									</div>
									<!--<ul class="comment-img">
                                        <li>
                                            <img render-src="coverUrl">
                                        </li>
                                    </ul>-->
									<hr/>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

</body>

</html>